JKTEBOP                                         
=======

 JKTEBOP v21   John Southworth  (Physics, Warwick Univ, j.k.taylor@warwick.ac.uk)
 A package for modelling the light curves of well-detached eclipsing binary stars

 Task 1  outputs limb and gravity darkening coefficients for given Teff and log g
 Task 2  outputs one model light curve calculated using a set of input parameters
 Task 3  finds the best fit of the model to observations (internal errors quoted)
 Task 4  finds the best fit to the observations, sigma clips, and refits the data
 Task 5  finds global best fit, by perturbing parameters and refitting many times
 Task 6  fits observations and finds goodness of fit for several parameter values
 Task 7  finds robust reliable errors by analysing with a bootstrapping algorithm
 Task 8  finds robust errors by analysing with a Monte Carlo simulation algorithm
 Task 9  finds robust errors using Monte Carlo given significant correlated noise

 Usage: '/home/drac/morales/bin/JKTEBOP.sh inputfile' to undertake the input task
 Usage: '/home/drac/morales/bin/JKTEBOP.sh newfile' to output an empty input file
 Usage: '/home/drac/morales/bin/JKTEBOP.sh 1' to undertake Task 1


Running JKTEBOP
---------------

You will need an input file giving the initial parameter values and other
information. This can be obtained by running JKTEBOP with this command:
  jktebop newfile

Once you have an input file (e.g. jkt_task3.in) run JKTEBOP with this command:
  jktebop jkt_task3.in

All output will be to text files - JKTEBOP does not create any graphics.

Files included
--------------

readme.txt        This file
jktebop.f         JKTEBOP version 21 source code
lc_2008_02_08.dat Data file to be fitted
jkt_plot.eps      Plot of the best fit (with gnuplot)


jkt_task3.in      Example input file
jkt_task3.par     Example output parameter file
jkt_task3.out     Example output light curve file (contains residuals)
jkt_task3.fit     Example output fit file (contains the best fit for plotting)

jkt_task7.in      Example input file for error determination by bootstrapping
jkt_task7.par     Example output parameter file
jkt_task7.fit     Example output fit parameters for each simulation

Code preamble
-------------

!=======================================================================
!     PROGRAM JKTEBOP               John Taylor  (jkt@astro.keele.ac.uk)
!                                 Astrophysics Group  Warwick University
!-----------------------------------------------------------------------
! V(1) = surface brightness ratio    V(15) = third light
! V(2) = sum of fractional radii     V(16) = phase correction
! V(3) = ratio of stellar radii      V(17) = light scaling factor
! V(4) = linear LD for star A        V(18) = integration ring size (deg)
! V(5) = linear LD for star B        V(19) = orbital period (days)
! V(6) = orbital inclination         V(20) = ephemeris timebase (days)
! V(7) = e cos(omega) OR ecentricity V(21) = nonlinear LD for star A
! V(8) = e sin(omega) OR omega       V(22) = nonlinear LD for star B
! V(9) = gravity darkening 1         VEXTRA(1) = primary star radius
! V(10)= gravity darkening 2         VEXTRA(2) = secondary star radius
! V(11) = primary reflected light    VEXTRA(3) = stellar light ratio
! V(12) = secondary reflected light  VEXTRA(4) = eccentricity
! V(13) = stellar mass ratio         VEXTRA(5) = periastron longitude
! V(14) = tidal lead/lag angle (deg) VEXTRA(6) = reduced chi-squared
! V(23-37) five lots of sine curve [T0,P,amplitude]
! V(38-67) five lots of polynomial [pivot,x,x2,x3,x4,x5]
!-----------------------------------------------------------------------
! Version 1: Simplex minimisation algorithm  and new input / output used
! Version 2: Monte Carlo simulation and parameter perturbation algorithm
! Version 3: Adjustments to Monte Carlo LD coeffs and input/output files
! Version 4: Now solves for sum of radii, convergence criterion modified
! Version 5: Added TASK0 to find LD and GD coeffs.   Minor modifications
! Version 6: Reflection and  scale  factor  can all be fixed or adjusted
! Version 7: Can use either (e,w) or (ecosw,esinw); SFACT modified to be
!            in magnitudes; observ'l errors found; spherical star option
! Version 8: Bootstrapping error analysis algorithm added and output mod
! Version 9: Command-line arguments allowed, Monte Carlo without parame-
!            eter kicking option, and fitting for period and Tzero added
! Version 10: Can now use 99999 datapoints. Whole code now in magnitudes
! Version 11: Bug fixes, tasks renumbered,  added sigma clipping and the
!             global fit procedures, but not thoroughly tested these yet
! Version 12: Nonlinear limb darkening law, fitting for times of minimum
!             light, and FMAX corrections included (from Alvaro Gimenez)
! Version 13: Removed  BILINEAR  and modified  TASK1  to just call JKTLD
!             Modified input file and arrays  for the diff types of data
! Version 14: Fixed the requirement for inputtd INTRING to be an integer
!             Fixed formal errors (when observational ones not supplied)
!             Sorted out numerical derivatives problem when  i ~ 90  deg
! Version 15: Added TASK 9 and cubic LD law, modified simulation output,
!             made MRQMIN a factor of 3 faster, and working on red noise
! Version 16: Added ability to include sine perturbations on parameters.
! Version 17: Added ability to specify a third light and its uncertainty
! Version 18: Made possible to fit for r1 and r2 instead of r1+r2 and k.
! Version 19: Added VARY=3 flag + finer fit phasing if r1 or r2 is small
! Version 20: Polynomial, optimisation check, TASK4 debug, DV centralise
! Version 21: Added input of ecosw and esinw observational constraints..
! Last modified:  18th September 2009  (working on WASP-18)
!-----------------------------------------------------------------------
! Possible modifications in future:
! 1) Extend to WD2003 and WINK.
! 2) Port to F90 or F95 to use long lines, modules, improved output.
! 3) Incorporate change of omega (apsidal motion).
! 4) Include radial velocities.
! 5) Include a light-time effect.
! 6) Allow for multiple light and radial velocity curves.
! 7) Try LD power law proposed by Hestroffer (1997A+A...327..199H).
!-----------------------------------------------------------------------
! Miscellaneous notes:
! 1) Phase shift has been redefined compared to original EBOP so that
!    it corresponds directly to the phase of the primary minimum.
! 2) MRQMIN adjusts coeffs only if VARY (called 'ia' in MRQMIN) is 1.
! 3) If VARY=2 then the parameter is fixed during the initial fit but is
!    perturbed by a set amount (flat distribution) for later analyses.
! 4) If VARY(11) and/or  VARY(12) are -1 then V(11) and/or V(12) are
!    calculated from the system geometry; if 0 they are fixed at the
!    input value and if 1 are freely adjusted to best fit.
! 5) If the mass ratio is <= 0 then both stars are assumed to be spheres
! 6) If ecosw > 5.0 then (ecosw,esinw) will be taken to be  (10+e,omega)
!    and fitting will occur using e and omega as parameters. e and omega
!    can be strongly correlated,  but this is useful if  e  is known but
!    omnega is not;   this can happen for EBs exhibiting apsidal motion.
! 7) Observational errors are looked for in the  input light curve file.
!    If they are not found then  equal weight  is given  to each  point.
! 8) Nonlinear LD is now supported for the two-coefficient  logarithmic,
!    quadratic and square-root laws.  The type of law must be specified.
!    on input.   Star B can also be forced to the same coeffs as star A.
!    BUT: normalisation for logarithmic not possible (not got equations)
! 9) Fitting for times of minimum light is directly possible.  The cycle
!    numbers and times are inputted  on lines  immediately below all the
!     parameter lines in the input file.
! 10) EBOP results are symmetric about 90 degrees for inclination (which
!     means i=89 gives same answer as i=91),  which causes problems with
!     numerical derivativs when i>89.9. In this case some extra is added
!     to the numerical derivative to keep the solution slightly below 90
! 11) If input k is negative then  (r1+r2,k)  is interpreted as  (r1,r2)
! 12) If  VARY=3  then the parameter is optimised during all fits but is
!     not perturbed by a set amount in later analyses (eg. Monte Carlo).
!-----------------------------------------------------------------------
! Task numbers and purposes:
! (1) This outputs LD coefficients for a given Teff, logg, [M/H], Vmicro
! (2) This outputs a model light curve for fixed input parameters.
! (3) This fits a model to an observed light curve and outputs results.
! (4) This fits a model, rejects discrepant observations, and refits.
! (5) This does a pseudo-global minimisation by perturbing input params.
! (6) This investigates how different parameters vary around best fit.
! (7) This conducts bootstrapping simulations to find robust errors.
! (8) This conducts Monte Carlo simulations to find robust errors.
! (9) This conducts residual permutations to deal with correlated noise.
!=======================================================================
! Language:  JKTEBOP is written in FORTRAN 77 using standard F77 syntax,
! with a few essentially straightforward extras, and compiled using g77.
! Possible non-F77 bits  ==  <=  <  >  >=  /=  !  and part-line comments
! I compile it with g77 -O -Wuninitialized -fbounds-check -fno-automatic
! The "-O" does some optimisation, but I find this has little effect.
! The "-fbounds-check" checks that array boundaries are respected.
!=======================================================================
!=======================================================================
